<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<%@include file="../../../include/meta.jsp"%>
<title>用户管理-通用权限管理系统</title>
<%@include file="../../../include/css.jsp"%>
<style type="text/css">
</style>
</head>
<body>
	<%@include file="../include/header.jsp"%>

	<nav aria-label="breadcrumb">
		<ol class="breadcrumb">
			<li class="breadcrumb-item"><a
				href="${pageContext.request.contextPath}/app/main.html"><i
					class="fas fa-home"></i>&nbsp;主页</a></li>
			<li class="breadcrumb-item">系统管理</li>
			<li class="breadcrumb-item active" aria-current="page">用户管理</li>
		</ol>
	</nav>

	<div class="container-fluid">
		<div class="row">
			<div class="col-2">
				<a class="btn btn-primary"
					href="${pageContext.request.contextPath}/app/user/add.html">添加</a>
				<a class="btn btn-success"
					href='${pageContext.request.contextPath}/app/user/list.html?page=${page}&size=${size}${where}'>刷新</a>
			</div>
			<div class="col-9">
				<form class="form-inline"
					action="${pageContext.request.contextPath}/app/user/list.html"
					method="post">
					<div class="form-group mx-sm-3 mb-2">
						<input type="text" class="form-control" id="name" name="name"
							value="${account.name}" placeholder="请输入用户名或登录名">
					</div>
					<button type="submit" class="btn btn-primary mb-2">查询</button>
				</form>
			</div>
			<div class="col-1">
				<a class="btn btn-secondary btn-block"
					href="${pageContext.request.contextPath}/app/main.html">返回</a>
			</div>
		</div>
		<br>
		<div class="row">
			<div class="col-12">
				<table class="table table-hover table-sm">
					<thead>
						<tr>
							<th scope="col">#</th>
							<th scope="col">姓名</th>
							<th scope="col">登录名</th>
							<th scope="col">禁用</th>
							<th scope="col">操作</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${list}" var="b" varStatus="vs">
							<tr>
								<th scope="row">${(page-1)*size+vs.count}</th>
								<td>${b.name}</td>
								<td>${b.loginName}</td>
								<td>${b.disabled?"禁用":"未禁用"}</td>
								<td><a class="btn btn-info btn-sm"
									href="${pageContext.request.contextPath}/app/user/edit.html?id=${b.id}&page=${page}&size=${size}${where}"
									title="编辑"><i class="fas fa-edit"></i></a> <a
									class="btn btn-danger  btn-sm" href="javascript:del('${b.id}')"
									title="删除"><i class="fas fa-trash-alt"></i></a></td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>
		</div>
		<div class="row">
			<c:if test="${total==0}">
				<div class="col-12 text-center">没有找到匹配的记录</div>
			</c:if>
			<c:if test="${total>0}">
				<div class="col-8">
					<p class="lead">第&nbsp;${page}&nbsp;页，共&nbsp;${pages}&nbsp;页（每页显示&nbsp;${size}&nbsp;条记录，共&nbsp;${total}&nbsp;条记录）</p>
				</div>
				<div class="col-4">
					<nav aria-label="Page navigation example">
						<ul class="pagination justify-content-end">
							<c:choose>
								<c:when test="${pages==0||pages==1}">
									<li class="page-item disabled"><a class="page-link">第一页</a></li>
									<li class="page-item disabled"><a class="page-link">上一页</a></li>
									<li class="page-item disabled"><a class="page-link">下一页</a></li>
									<li class="page-item disabled"><a class="page-link">最后一页</a></li>
								</c:when>
								<c:when test="${page==1}">
									<li class="page-item disabled"><a class="page-link">第一页</a></li>
									<li class="page-item disabled"><a class="page-link">上一页</a></li>
									<li class="page-item"><a class="page-link"
										href="${pageContext.request.contextPath}/app/user/list.html?page=${page+1}&size=${size}${where}">下一页</a></li>
									<li class="page-item"><a class="page-link"
										href="${pageContext.request.contextPath}/app/user/list.html?page=${pages}&size=${size}${where}">最后一页</a></li>
								</c:when>
								<c:when test="${page==pages}">
									<li class="page-item"><a class="page-link"
										href="${pageContext.request.contextPath}/app/user/list.html?page=1&size=${size}${where}">第一页</a></li>
									<li class="page-item"><a class="page-link"
										href="${pageContext.request.contextPath}/app/user/list.html?page=${page-1}&size=${size}${where}">上一页</a></li>
									<li class="page-item disabled"><a class="page-link">下一页</a></li>
									<li class="page-item disabled"><a class="page-link">最后一页</a></li>
								</c:when>
								<c:otherwise>
									<li class="page-item"><a class="page-link"
										href="${pageContext.request.contextPath}/app/user/list.html?page=1&size=${size}${where}">第一页</a></li>
									<li class="page-item"><a class="page-link"
										href="${pageContext.request.contextPath}/app/user/list.html?page=${page-1}&size=${size}${where}">上一页</a></li>
									<li class="page-item"><a class="page-link"
										href="${pageContext.request.contextPath}/app/user/list.html?page=${page+1}&size=${size}${where}">下一页</a></li>
									<li class="page-item"><a class="page-link"
										href="${pageContext.request.contextPath}/app/user/list.html?page=${pages}&size=${size}${where}">最后一页</a></li>
								</c:otherwise>
							</c:choose>
						</ul>
					</nav>
				</div>
			</c:if>
		</div>
	</div>

	<%@include file="../../../include/js.jsp"%>
	<script type="text/javascript">
		function del(id){
			if(confirm("此操作将永久性的删除数据不可恢复，是否继续？")){
				window.location.href="${pageContext.request.contextPath}/app/user/delete.html?id="+id+"&page=${page}&size=${size}";
			}
		}
	</script>
</body>
</html>